From: William Manley Date: Tue, 26 Jul 2016 16:42:17 +0000 (+0100) Subject: switchroot: Fix building with musl libc X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~48^2~5 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22%22?a=commitdiff_plain;h=faee3df8ae244896f531ab7ad00c8ea75f148da3;p=ostree.git switchroot: Fix building with musl libc POSIX and GNU define conflicting versions of `strerror_r`. The GNU version returns the string but doesn't necessilary write into buf. The POSIX version writes into buf and returns the length but doesn't necessilary append a terminate the string with a NUL if it's too long to fit in buf. This commit fixes building ostree-prepare-root with musl libc. The stripped static build with musl on my machine is 30K vs. 724K with glibc static and 11K with glibc shared. Closes: #477 Approved by: cgwalters --- diff --git a/src/switchroot/ostree-mount-util.c b/src/switchroot/ostree-mount-util.c index bb27026c..9789bd86 100644 --- a/src/switchroot/ostree-mount-util.c +++ b/src/switchroot/ostree-mount-util.c @@ -40,7 +40,13 @@ perrorv (const char *format, ...) char buf[1024]; char *p; +#ifdef _GNU_SOURCE p = strerror_r (errno, buf, sizeof (buf)); +#else + strerror_r (errno, buf, sizeof (buf)); + buf[sizeof (buf) - 1] = '\0'; + p = buf; +#endif /* _GNU_SOURCE */ va_start (args, format);